<template>
  <div id="app">
    <pageHeader master="我的发布" address="home/mine"/>
    <div class="wrapper" ref="wrapper">
      <div class="contain">
        <div v-if="list.length > 0">
          <div class="content" v-for="(item, index) in list" :key="index">
            <div class="block">
              <left
                :id="item[0]"
                :category="item[2]"
                :master="item[6]"
                :img="item[4]"
                :time="item[7]"
                :wx="item[8]"
                :address="item[1]"
                :userid="item[3]"
              ></left>
              <right
                :avid="item[0]"
                :userid="item[3]"
                :category="item[2]"
                @getNewmsg="getmsg"
              ></right>
            </div>
          </div>
        </div>
        <div class="nullDataTip" v-else>
          <img src="~@/assets/nullTip.png" />
          <button class="nullDataBtn" @click="toPublishIndex">
            <b>去发布活动</b>
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import pageHeader from "../../components/pageHeader2/index.vue";
import BScroll from "better-scroll";
import left from "../../components/activityLeft2/index.vue";
import right from "../../components/activityRight2/index.vue";
export default {
  name: "",
  data() {
    return {
      list: [],
    };
  },
  components: {
    pageHeader,
    left,
    right,
  },
  methods: {
    toPublishIndex() {
      this.$router.push({
        path: "home/publish",
      });
    },
    getmsg(res) {
      this.list = res;
    },
  },
  watch: {
    list: function() {
      this.$nextTick(() => {
        this.scroll = new BScroll(this.$refs.wrapper, {
          mouseWheel: true, //开启鼠标滚轮
          disableMouse: false, //启用鼠标拖动
          disableTouch: false, //启用手指触摸
          click: true,
        });
      });
    },
  },
  created() {
    var that = this;
    this.axios
      .get("http://120.78.199.38:9000/activity/getMineActivity", {
        params: {
          userid: that.$store.state.yb_userid,
        },
      })
      .then((res) => {
        // console.log(res.data);
        that.list = res.data;
      });
  },
};
</script>
<style scoped>
#app {
  height: 100%;
  width: 100%;
}
.block {
  height: 92%;
  width: 92%;
  position: relative;
  left: 4%;
  top: 4%;
  background-color: white;
  border-radius: 15px;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
}
.wrapper {
  position: relative;
  height: 93%;
  width: 100%;
  background-color: rgb(236, 234, 240);
  overflow: hidden;
}
.contain {
  width: 100%;
}
.content {
  height: 22vh;
  width: 100%;
}
.nullDataTip {
  width: 50%;
  height: 100%;
  line-height: 100%;
  margin: auto;
  margin-top: 100px;
}
.nullDataBtn {
  width: 60%;
  border-radius: 10px;
  border-style: solid;
}
.nullDataTip {
  width: 50%;
  height: 100%;
  line-height: 100%;
  margin: auto;
  margin-top: 100px;
}
.nullDataBtn {
  width: 60%;
  border-radius: 10px;
  border-style: solid;
  font-size: 15px;
  /* margin-left: 25px; */
  position: relative;
  left: 24px;
  margin-top: 10px;
  color: rgb(151, 148, 148);
}
</style>
